import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-31
 * Time:17:09
 */
public class Pokers {
    public List<Poker> buyPoker(){
        List<Poker> list=new ArrayList<>(52);//13*4=52

        String[] suits={"♠","♥","♣","♦"};

        for (int i = 0; i < suits.length; i++) {

            for (int j = 1; j <= 13 ; j++) {

                String suit=suits[i];
                int num=j;

                Poker poker=new Poker(suit,num);

                list.add(poker);
            }
        }
        return list;
    }
    //交换
    public void Swap(List<Poker> list,int i,int j){

        Poker temp=list.get(i);

        list.set(i,list.get(j));

        list.set(j,temp);
    }
//洗牌可以理解为互相交换牌
    public void Shuffle(List<Poker> list){
        Random random=new Random();//随机数发生器

        //注意这里是i从最后的元素开始，这样会让牌洗的更干净
        for (int i = list.size()-1; i > 0; i--) {

            int ret=random.nextInt(i);//随机生成【0，i)之间的数字

            Swap(list,i,ret);

        }
    }

}
